home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 19
/
Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso
/
Aminet
/
comm
/
maxs
/
dfbv13.lha
/
dfb
/
Developers
/
dfb_read.s
< prev
next >
Wrap
Text File
|
1996-06-01
|
3KB
|
145 lines
;
; DFB_read - Example of how to open the file base, read in the files and
; also how to use the built in display routine
; This programme lists all files to the current CLI window in ANSI
; text.
include exec/types.i
include exec/exec_lib.i
include exec/memory.i
include exec/strings.i
include libraries/dos_lib.i
include libraries/dos.i
include dfb.i
include dfb_lib.i
lea dfbname,a1 ;load all needed libraries
moveq #0,d0
CALLEXEC OpenLibrary
tst.l d0
beq nolibrary
move.l d0,_dfbbase
lea dosname,a1
moveq #0,d0
CALLEXEC OpenLibrary
tst.l d0
beq nodoslibrary
move.l d0,_dosbase
CALLDOS Output ;get output handle since we are
move.l d0,CliHandle ;writing to CLI window
move.l #ATSTART,d0 ;we want to read forward so go start
CALLDFB OpenFileBase ;open the file base
tst.l d0
beq nofilebase
move.l d0,a5
ReadNextFile
clr.l d4
move.w of_nextlength(a5),d4 ;get the length of the next
tst.w d4 ;file node. So we can allocate
beq nomorefiles ;enough memory to load it
move.l d4,d0 ;if d4=0 no more files.
move.l #MEMF_PUBLIC,d1
CALLEXEC AllocMem
tst.l d0
beq nomorefiles
move.l d0,a4
move.l d0,a0 ;memory for file node
move.l a5,d0 ;file base handle
clr.l d1 ;standard mode
readfile
CALLDFB ReadNextFile ;Read the next file node in
tst.l d0
bne errorinread ;any problems?
move.l a4,a0 ;file node to display
btst #fbb_astalavista,fb_status(a4) ;use this file node ?
bne DonePrinting
lea freespace,a1 ;free space (1Kb)
lea clearbyte,a2 ;no marked files, so point to empty byte
move.l a5,a3 ;file base handle
suba.l a4,a4 ;use standard layout data
clr.l d0 ;length of marked list
clr.l d1 ;no name offset
clr.l d2 ;display all data
move.l #5000,d3 ;list files as so we were a sysop (access 5000)
CALLDFB DisplayNode ;this puts everything into a nice text format
move.l a0,a3 ;a0 points to a list of pointers of the text lines
alllines
move.l (a3)+,a2 ;get first (next) line
cmpa.l #0,a2 ;are there anymore lines?
beq doneprinting
bsr getstringlength ;work out line length for Write
move.l clihandle,d1
move.l a2,d2
move.l d0,d3
CALLDOS Write ;Write it to display
bsr printreturn ;Return
bra alllines
doneprinting
bsr freenodemem ;free this file nodes memory
bra ReadNextFile ;repeat until no more files
errorinread
bsr freenodemem
nomorefiles
move.l a5,d1 ;Close everything
CALLDFB CloseFileBase
nofilebase
move.l _dosbase,a1
CALLEXEC CloseLibrary
nodoslibrary
move.l _dfbbase,a1
CALLEXEC CloseLibrary
nolibrary
rts
getstringlength
clr.l d0
move.l a2,a0
keepcounting
addq.l #1,d0
tst.b (a0)+
bne keepcounting
rts
printreturn
move.l clihandle,d1
move.l #return,d2
move.l #3,d3
CALLDOS Write
rts
freenodemem
move.l a4,a1
move.l d4,d0
CALLEXEC FreeMem
rts
dfbname DFBNAME
dosname DOSNAME
return dc.b lf,cr,0
SECTION DemoData,BSS
_dfbbase ds.l 1
_dosbase ds.l 1
clihandle ds.l 1
freespace ds.b 1024
clearbyte ds.b 1